package sketch.ast;

import java.util.List;

import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;

import sketch.util.Checker;

public class Demo {
	
	public static void main(String[] args) {
		String filePath = "/scratch/eclipseworkspace/SketchSeq/examples/TreeMapSketchExecution.java";
		CompilationUnit unit = ASTUtils.astRoot(filePath);
		List<AbstractTypeDeclaration> types = ASTUtils.typeDeclarations(unit);
		TypeDeclaration typeDeclaration = ASTUtils.getTypeDeclaration(types, "GenTest");
		MethodDeclaration methodDeclaration = ASTUtils.getScratchTest(typeDeclaration, "scratchTest");
		//check that scratchTest must exist
		Checker.checkNull(methodDeclaration, "There is no method called scratchTest");
		
		HoleExtractionVisitor visitor = new HoleExtractionVisitor(methodDeclaration);
		visitor.visit(methodDeclaration);
		
		MethodDeclarationWithHoles methodHoles = visitor.getTransformedMethod();
		System.out.println(methodHoles);
	}
}